function addFavorite(url,title) {
	var ua = navigator.userAgent.toLowerCase();
	if(ua.indexOf("msie")>-1){
		//alert("加入收藏失败，请使用Ctrl+D进行添加");
		//window.external.addToFavoritesBar(url,title,'slice');//IE8
		try {
			window.external.addToFavoritesBar(url,title,'slice');//IE8
		} catch(e) {
			alert("加入收藏失败，请使用Ctrl+D进行添加");
		}
	}else{
		try {
			window.external.addFavorite(url, title);
		} catch(e) {
			try {
				window.sidebar.addPanel(title, url, "");//firefox
			} catch(e) {
				alert("加入收藏失败，请使用Ctrl+D进行添加");
			}
		}
	}
}

function SetHome(obj,vrl){
	try{
		obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
	}catch(e){
		if(window.netscape) {
			try {
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
			}catch (e){
				alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。");
			}
			var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
			prefs.setCharPref('browser.startup.homepage',vrl);
		}else{
			alert("设置主页失败，请手动在浏览器中设置");	
		}
	}
}
//获取指定对象
function G() {
var elements = new Array();
for (var i = 0; i < arguments.length; i++) {
	var element = arguments[i];
	if (typeof element == 'string')
		element = document.getElementById(element);
	if (arguments.length == 1)
	return element;
	elements.push(element);
}
return elements;
}
function autoSelect(itm, val){
var o=G(itm);
for (i=0;i<o.options.length;i++){
	if(o.options[i].value==val){
		o.selectedIndex = i;
		break;
	}
}
}
function addoptions(obj,text,val){
var o=G(obj);
var opt = document.createElement('OPTION');
opt.text = text;
opt.value = val;
o.options.add(opt, o.length);
}
function autoCheckbox(itm, val){
var o=document.getElementsByName(itm);
var vals=val.split(",");
for (var s=0;s<vals.length;s++){
	for (i=0;i<o.length;i++){
		if(o[i].value==vals[s]){
			o[i].checked= true;
			break;
		}
	}
}
}
function autoRadio(itm,val){
var o=document.getElementsByName(itm);
for(var i=0;i<o.length;i++){
	if(o[i].value==val){
		o[i].checked=true;
		break;
	}	
}
}
function autoInput(itm,val){
var o=G(itm);
o.value=val;
}
//弹出窗口
function wo(url,w,h,m){
	var left=(screen.width-w)/2;
	var top=m?(screen.height-h)/2:0;
	window.open(url,'','width='+w+',height='+h+',top='+top+',left='+left+',scrollbars=1,resizable=0,status=0');
	//return false;
}
//弹出窗口
function wo2(url,w,h,m){
	var left=(screen.width-w)/2;
	var top=m?(screen.height-h)/2:0;
	window.open(url,'','width='+w+',height='+h+',top='+top+',left='+left+',scrollbars=0,resizable=0,status=0');
	//return false;
}
//获取图片宽度
function getWidth(ele){
var image=new Image(); 
image.src=ele.src;
return image.width;
}
//获取图片高度
function getHeight(ele){
var image=new Image(); 
image.src=ele.src;
return image.height;
}
function updateimgs(Img,w,h){
	var widths = w;
	var heights = h;
	var objimg = Img;
	var iwidth=getWidth(objimg);
	var iheight=getHeight(objimg);
	if(iwidth<widths && iheight<heights){
		return;
	}
	if(iwidth/iheight>widths/heights)
	{
		objimg.width=widths;
		objimg.height=widths*iheight/iwidth;
		return;
	}else{
		objimg.width=heights*iwidth/iheight;
		objimg.height=heights;
		return;
	}
}
//自动绽放图片
function AutoImg(o,w){
var Imgs=G(o).getElementsByTagName("img");	
for(var j=0; j<Imgs.length; j++) {
	autoImgW(Imgs[j],w);
	Imgs[j].style.cursor= "pointer"; 
	Imgs[j].onclick = function() {window.open(this.src);};
	//Imgs[j].onerror = function() {this.src='/images/nopic.gif';};
}
}
//自动缩放图片到指定宽度
function autoImgW(Img,w)
{
var widths = w;
var objimg = G(Img);
var iwidth=getWidth(objimg);
if(iwidth>widths) objimg.width=widths;
}
//自动缩放图片到指定高度
function autoImgH(Img,h)
{
var heights = h;
var objimg = G(Img);
var iheight=getHeight(objimg);
if(iheight>heights) objimg.height=heights;
}
//行高滚动
function startmarquee(lh,speed,delay,obj){
var t;
var p=false;
var o=G(obj);
o.innerHTML+=o.innerHTML;
o.onmouseover=function(){p=true}
o.onmouseout=function(){p=false}
o.scrollTop = 0;
function start(){
t=setInterval(scrolling,speed);
if(!p) o.scrollTop += 2;
}
function scrolling(){
if(o.scrollTop%lh!=0){
	o.scrollTop += 2;
	if(o.scrollTop>=o.scrollHeight/2) o.scrollTop = 0;
}else{
	clearInterval(t);
	setTimeout(start,delay);
}
}
setTimeout(start,delay);
}
//反选
function uchoose(form){
var checkbox=form.elements;
for (var i=0;i<checkbox.length;i++)
	if (checkbox[i].type=="checkbox"){
		var e = checkbox[i];
		if (e.checked==false)
			e.checked = true;
		else
			e.checked = false;
	}
} 
//全选
function choose(form){
var checkbox=form.elements;
for (var i=0;i<checkbox.length;i++)
	if (checkbox[i].type=="checkbox"){
		var e = checkbox[i];
		if (e.checked==false)
			e.checked = true;
	}
}

function getdate(o){
var datestr;
var Week = ['日','一','二','三','四','五','六'];
var date=new Date();
datestr=date.getFullYear()+"年"+(date.getMonth()+1)+"月"+date.getDate()+"日 星期"+Week[date.getDay()];
G(o).innerHTML=datestr;
}
function getdate2(o){
var datestr;
var date=new Date();
datestr='<span class="red" style="font-size:16px; font-weight:bold;">'+ date.getFullYear() +'</span><span style="font-size: 16px"> 年<span class="red" style="font-weight:bold;">'+ (date.getMonth()+1) +'</span>月<span class="red" style="font-weight:bold;">'+ date.getDate()+ '</span>日</span>';
G(o).innerHTML=datestr;
}
function get_Code(CodeFile,w,h,id) {
	if(document.getElementById("codeid"))
		document.getElementById("codeid").innerHTML = '<img src="'+CodeFile+'?t='+Math.random()+'" alt="点击刷新验证码" style="cursor:pointer;border:0;vertical-align:middle;" width="'+ w +'" height="'+ h +'" onclick="this.src=\''+CodeFile+'?t=\'+Math.random()" />';
		//width="60" height="18" 
}
/*o end*/